<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>DHTML Tree samples. dhtmlXTree - User data</title>
</head>
<style>
	body {font-size:12px}
	.{font-family:arial;font-size:12px}
	h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
</style>
<body>
	<h1> User data</h1>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<script  src="../js/dhtmlXCommon.js"></script>
	<script  src="../js/dhtmlXTree.js"></script>
    <script  src="../js/dhtmlXTree_xw.js"></script>
    Any item in tree or tree itself can have assigned data. <br/>
    Assignment can be done through API or through initialization XML. 
	<table>
		<tr>
			<td valign="top">
				<div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
			</td>
			<td rowspan="2" style="padding-left:25" valign="top">
			
			
			<a href="javascript:void(0);" onclick="alert(tree.getUserData(0,document.getElementById('tuds').value))">Get tree user data(was preseted from XML)</a> <select id="tuds"><option value="author">author<option value="mode">mode<option value="created">created</select><br>
			<a href="javascript:void(0);" onclick="alert(tree.getUserData(0,document.getElementById('tud1').value))">Get tree user data</a><input id="tud1" type="text"><br>
			<a href="javascript:void(0);" onclick="tree.setUserData(0,document.getElementById('tud2').value,document.getElementById('tud3').value)">Set tree user data: </a> name<input id="tud2" type="text">, value <input id="tud3" type="text"><br><br>
			
			<a href="javascript:void(0);" onclick="alert(tree.getUserData(tree.getSelectedItemId(),document.getElementById('iud1').value))">Get item user data</a><input id="iud1" type="text"><br>
			<a href="javascript:void(0);" onclick="tree.setUserData(tree.getSelectedItemId(),document.getElementById('iud2').value,document.getElementById('iud3').value) ">Set item user data: </a> name<input id="iud2" type="text">, value <input id="iud3" type="text"><br>
            <a href='#' onclick='document.getElementById("a_ter").innerHTML=wellform(tree.serializeTree())'>Serialize</a>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>
	<hr>	
<XMP>
<div id="treeboxbox_tree" style="width:200;height:200"></div>
<script>
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.loadXML("tree.xml");

			....
			//set user data
			tree.setUserData(id,"name","value");
			//get user data
			tree.getUserData(id,"name");
</script>
</XMP>
	<script>
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.enableDragAndDrop(true);
            tree.setSerializationLevel(true,false);
			tree.loadXML("tree_ud.xml");


function wellform(a){
    return a.replace(/</g,"&lt;").replace(/>/g,"&gt;<br/>");
}
	</script>
<br><br>
  <div id='a_ter'>1</div>
</body>
</html>

